home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: merge algorithm
- Date: 28 Feb 1996 15:52:49 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h2pshINN47q@anvil.ugrad.cs.ubc.ca>
- References: <312CEE69.842@onyx.idbsu.edu> <4gljrl$auj@sun001.spd.dsccc.com> <825461208snz@genesis.demon.co.uk>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <825461208snz@genesis.demon.co.uk>,
- Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
- >In article <4gljrl$auj@sun001.spd.dsccc.com>
- > jmccarty@spd.dsccc.com "Mike McCarty" writes:
- >
- >>In article <312CEE69.842@onyx.idbsu.edu>,
- >>Joe E. Coffland <jcofflan@onyx.idbsu.edu> wrote:
- >>)I am trying to find an algorithm to merge two sorted arrays containing
- >>)n elements.
- >>)ie. A[1] <= A[2]<= ... <= A[m] and A[m+1] <= A[m+2] <= ... <A[n]
- >>)The algorithm must run in O(n) time and require only a small amount of
- >>)fixed additional memory regardless of the size of m or n. I have reason
- >>)to believe that there is such an algorithm but I have only been able to
- >>)find algorithms that meet the memory restriction but run in at best
- >>)O(nlogn) and are recursive (which can through some work of course be
- >>)changed in to an iterative algorithm). If any one can point me to a book
- >>)or any other source of information on the subject or just get me headed
- >>)in the right direction it would be greatly appriciated.
- >
- >As far as I am aware there is no such algorithm although I'd be very
- >happy to be proved wrong. One obvious O(nlogn) algorithm is heapsort.
-
- It seems that way, but it's hard to ignore the fact that merging two sorted
- arrays given enough additional memory is an O(n) operation, which suggests
- that some clever (yet inexpensive) rearrangement of the input may be conducive
- to a a solution better than O(nlogn). Things are not always as they seem.
- One has to only consider the cleverness of the Fast Fourier Transform.
- --
-
-